<link  href="/stylesheets/tests.css" type="text/css" rel="stylesheet" media="screen">

<br/>
<p  class="smallNav">专业量表管理>></p>
<div style="margin: 15px 0 10px 0">
  <%= link_to '创建量表', :controller => "prof_surveys", :action => "new" %>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <% if  @status %>
  <a href="/surveys/prof_surveys" >全部量表</a>
  <% else %>
  <a href="/surveys/prof_surveys?status=finshed" >已启用量表</a>
  <% end %>
  &nbsp;&nbsp;&nbsp;
  <%= link_to '分类管理', :controller => "prof_surveys", :action => "new_type" ,:id=> 1%>

</div>

<div>
  <font color="green">量表总数：<%= @total_num %></font>&nbsp;&nbsp;
  <font color="green">已启用量表数：<%= @used_num %></font>&nbsp;&nbsp;
  <font color="green">分类数量：<%= @type_num %></font>&nbsp;&nbsp;
</div>

<table class="datalist">
  <tr>
    <th scope="col" width="200">测试</th>
    <th scope="col" width="65">录入者</th>
    <th scope="col" width="40">概要</th>
    <th scope="col">
      <% if @order %>

      <a href="/surveys/prof_surveys">
      <% else %>
      <a href="/surveys/prof_surveys?order=test_type_id" >
      <% end %>
        <font color="blue">测试类型</font>
      </a>
    </th>
    <th scope="col">状态</th>
    <th></th>
  </tr>
  
  <% 
    i = 0  
    @tests.each do |test| 
  %>
    <% if i%2 == 0 %>
  <tr>
    <% else %>
  <tr  class="altrow">    
    <% end %>
    
    <td><%=test.name %></td>
    <% if test.user %>
    <td><%=test.user.username%></td>
    <% else %>
    <td></td>
    <%end %>
    <td></td>
    <td><%=h test.survey_type.name %></td>
    <td>
      <% if test.status == TEST_STATUS_FINISHED %>
      <font color="green">
      <% end %>
      <%= test.status %>
      <% if test.status == TEST_STATUS_FINISHED %>
      </font>
      <% end %>
    </td>
    
    <td>
      <%= link_to '编辑', {:id => test, :controller => "prof_surveys", :action => :edit }%>
      <%= link_to '添加图片' , {:id=>test, :action=>:add_image_fortest} %>
      <%=link_to '预测' ,{:id => test, :controller => "prof_surveys", :action => :pre_test }%>
      <% if current_user.username == "admin" %>
        <%= link_to '启用', {:id => test, :controller => "prof_surveys", :action => :finish}  %>
        <%= link_to '停用', {:id => test, :controller => "prof_surveys", :action => :stop}  %>
      <% end %>
      <a onclick="return confirm('确定删除?');" href="/surveys/prof_surveys/destroy/<%=test.id%>">删除</a>
      
    </td>
  </tr>
  <% 
    i += 1
    end 
  %>

</table>
<%=will_paginate(@tests ,:prev_label=>'上一页',:next_label=>'下一页',:separator=>" | ") %>
<br/>
